package com.demo.config.template;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.demo.common.kit.SessionKit;
import com.demo.shiro.tag.HasPermissionTag;
import com.demo.shiro.tag.PrincipalTag;
import com.demo.shiro.tag.ShiroTag;
import com.jfinal.template.ext.spring.JFinalViewResolver;
import com.jfinal.template.source.ClassPathSourceFactory;

@Configuration
public class SpringBootConfig {
	@Bean(name = "jfinalViewResolver")
	public JFinalViewResolver getJfinalViewResolver() {
		JFinalViewResolver jfvr = new JFinalViewResolver();
		jfvr.setDevMode(true);
		jfvr.setSourceFactory(new ClassPathSourceFactory());
		jfvr.setPrefix("/view/front/");
		jfvr.setSuffix(".html");
		jfvr.setContentType("text/html;charset=UTF-8");
		jfvr.setOrder(0);
		jfvr.setSessionInView(true);
		jfvr.setSharedFunction("/view/common/common.html");
		jfvr.setSharedFunction("/view/common/paginate.html");
		jfvr.addSharedObject("shiro", new ShiroTag());
		jfvr.addDirective("hasPermission", new HasPermissionTag());
		jfvr.addDirective("principal", new PrincipalTag());
		return jfvr;
	}
}
